//
//  WULIChangeUserInfoAPI.m
//  WULIHH
//
//  Created by Gamefire on 16/5/3.
//  Copyright © 2016年 tang. All rights reserved.
//

#import "WULIChangeUserInfoAPI.h"
#import "Header.h"
#import "AFNetworking.h"
#import "UserInfoModel.h"

@implementation WULIChangeUserInfoAPI

+ (id)putUserInformation:(NSDictionary *)dic
{
    NSString *httpString = [NSString stringWithFormat:@"%@%@%@",hostName, @"user/", [UserInfoModel userIDString]];
    NSLog(@"%@", httpString);
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    [manager.requestSerializer setValue:[UserInfoModel tokenString] forHTTPHeaderField:@"X-AUTH-TOKEN"];
    [manager.requestSerializer setValue:appVersion forHTTPHeaderField:@"X-APP-VERSON"];
    [manager.requestSerializer setValue:typetext forHTTPHeaderField:@"Content-Type"];
    
    
    //    AFWithToken *manager = [AFWithToken shareInter];
    
    
    [manager PUT:httpString parameters:dic success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        // 请求成功，解析数据
        //        NSLog(@"%@", responseObject);
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];
        
        [[NSNotificationCenter defaultCenter] postNotificationName:@"xiugaiuser" object:nil userInfo:dic];
        
//        NSLog(@"-----------------%@", dic);
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        // 请求失败
        NSLog(@"%@", [error description]);
    }];

    return self;
}


@end
